package com.sun.object;

import java.io.Serializable;
import org.apache.http.message.BasicNameValuePair;

public class Parameter extends BasicNameValuePair implements Serializable, Comparable<Parameter> {

	private static final long serialVersionUID = 2721340807561333705L;
	
	private String name;
	private String value;
	
	public Parameter(String name, String value) {
		super(name, value);
	}
	
	public Parameter(String name, Object value) {
		this(name, value.toString());
	}

	@Override
	public String toString() {
		return "Parameter [name=" + name + ", value=" + value + "]";
	}

	@Override
	public boolean equals(Object o) {
		if(o==null || !(o instanceof Parameter))
			return false;
		
		if(this == o)
			return true;
		else{
			Parameter param = (Parameter)o;
			return this.getName().equals(param.getName()) && this.getValue().equals(param.getValue());
		}
	}

	public int compareTo(Parameter another) {
		int compare = this.name.compareTo(another.getName());
		
		if(0==compare)
			return this.value.compareTo(another.getValue());
		else
			return compare;
	}
}
